package com.itheima.controller;

import com.itheima.common.Result;
import com.itheima.service.HomeService;
import com.itheima.vo.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/index")
public class HomeController {
    private final HomeService homeService;

    @GetMapping("/index")
    public Result<FrontHomeVO> getAllList() {
        FrontHomeVO frontHomeVO = homeService.getAllList();
        return Result.success(frontHomeVO);
    }

    @GetMapping("/new")
    public Result<EssayDataVO> getAllEssayList(Integer page, Integer limit) {
        EssayDataVO essayDataVO = homeService.getAllEssayList(page, limit);
        return Result.success(essayDataVO);
    }

    @GetMapping("/hot")
    public Result<HotEssayAllVO> getAllHotEssayList() {
        HotEssayAllVO hotEssayAllVO = homeService.getAllHotEssayList();
        return Result.success(hotEssayAllVO);
    }

    @GetMapping("/recommend")
    public Result<HotEssayAllVO> getAllTopEssayList() {
        HotEssayAllVO hotEssayAllVO = homeService.getAllTopEssayList();
        return Result.success(hotEssayAllVO);
    }

    @GetMapping("/list")
    public Result<AllListVO> getList(Integer page, Integer limit,Integer cateid) {
        AllListVO allListVO = homeService.getList(page,limit,cateid);
        return Result.success(allListVO);
    }

    @GetMapping("/show")
    public Result<ShowEssayVO> getList(Integer id) {
        ShowEssayVO showEssayVO = homeService.getShowList(id);
        return Result.success(showEssayVO);
    }
}
